package com.ice.work.moment.facade.crawler.controller;


import com.honeybee.cloud.framework.common.annotation.ApiVersion;
import com.honeybee.cloud.framework.common.response.ResponseEntity;
import com.ice.work.moment.facade.crawler.controller.fallback.CrawlerHystrixFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @Description 爬虫任务
 * @Author DELL
 * @Create 2019-04-29
 * @Since 1.0.0
 */
@FeignClient(name = "${spring.application.name}", fallbackFactory = CrawlerHystrixFallbackFactory.class)
@RequestMapping("crawler-task")
public interface ICrawlerTaskController {

    /**
     * 爬取所有A股列表
     *
     * @param size 页数
     * @return
     */
    @RequestMapping(name = "爬取所有A股列表", value = "a-share", method = RequestMethod.GET)

    ResponseEntity<Void> getAllAShare(@RequestParam(defaultValue = "1", name = "size", value = "size") Integer size);

    /**
     * 爬取所有A股详情
     *
     * @return
     */
    @RequestMapping(name = "爬取所有A股详情", value = "a-share/all-trading-detail", method = RequestMethod.GET)
    ResponseEntity<Void> getAllShareTrading();

    /**
     * 爬取单个A股详情
     *
     * @param id
     * @return
     */
    @RequestMapping(name = "爬取单个A股交易详情", value = "a-share/{id}/trading-detail", method = RequestMethod.GET)
    @ApiVersion(2)
    ResponseEntity<Void> getAShareTrading(@PathVariable(name = "id", value = "id") Long id);


    /**
     * 爬取所有评论信息
     *
     * @param size    页数
     * @param shareId
     * @return
     */
    @RequestMapping(name = "爬取所有评论信息", value = "a-share/all-comment-detail", method = RequestMethod.GET)
    ResponseEntity<Void> getAllShareComment(@RequestParam(defaultValue = "1", name = "size", value = "size") Integer size, @RequestParam(name = "shareId", defaultValue = "") Long shareId);

    /**
     * 爬取持仓类型
     *
     * @return
     */
    @RequestMapping(name = "爬取持仓类型", value = "position-type", method = RequestMethod.GET)
    ResponseEntity<Void> getPositionType();

    /**
     * 爬取持仓信息
     *
     * @param size 页数
     * @return
     */
    @RequestMapping(name = "所有持仓信息", value = "position-item", method = RequestMethod.GET)
    ResponseEntity<Void> getPosition(@RequestParam(defaultValue = "1", name = "size", value = "size") Integer size);

    /**
     * 测试策略模式
     *
     * @param type 类型
     * @return
     */
    @RequestMapping(name = "测试策略模式", value = "strategy/{type:\\d+}", method = RequestMethod.GET)
    ResponseEntity<String> testStrategy(@Validated @PathVariable Integer type);

}
